<?php
session_start();
$loadboard = mysql_query("select e.IDEmployee, e.FullName,b.* from employee e, board b where e.IDEmployee = b.IDEmployee order by b.CreatedDate desc");

?>
<script type="text/javascript">
function onclickAddNewNotice(els){
	if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else
	  {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp.onreadystatechange=function()
	  {
	  if (xmlhttp.readyState==4 && xmlhttp.status==200)
	    {
	        document.getElementById("generalnotice").innerHTML=xmlhttp.responseText;
	        loadeditor();
	    }
	  }
	var lang = '<?=$_SESSION['lang']?>';
	xmlhttp.open("GET","admin/employeemanagement/new-general-notice.php?newlang="+lang,true);
	xmlhttp.send();

	function loadeditor(){
        var editor = CKEDITOR.replace("ncontent");
  	  	CKFinder.setupCKEditor(editor, '../ckfinder') ;
	}
}
function onclickback(els){
	if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else
	  {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp.onreadystatechange=function()
	  {
	  if (xmlhttp.readyState==4 && xmlhttp.status==200)
	    {
	        document.getElementById("generalnotice").innerHTML=xmlhttp.responseText;
	    }
	  }
	xmlhttp.open("GET","admin/employeemanagement/content-genaral-notice.php",true);
	xmlhttp.send();

}
function processPreviewNotice(idboard,els){
	if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else
	  {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp.onreadystatechange=function()
	  {
	  if (xmlhttp.readyState==4 && xmlhttp.status==200)
	    {

	        document.getElementById("generalnotice").innerHTML=xmlhttp.responseText;
	        
	    }
	  }
	var lang = '<?=$_SESSION['lang']?>';
	xmlhttp.open("GET","admin/employeemanagement/preview-general-notice.php?idboard="+idboard+"&newlang="+lang,true);
	xmlhttp.send();
}

function processDeleteNotice(idboard,idemployee,els)
{
	if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else
	  {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp.onreadystatechange=function()
	  {
	  if (xmlhttp.readyState==4 && xmlhttp.status==200)
	    {
	        document.getElementById("generalnotice").innerHTML=xmlhttp.responseText;
	    }
	  }
	var lang = '<?=$_SESSION['lang']?>';
	xmlhttp.open("GET","admin/employeemanagement/process-delete-general-notice.php?idboard="+idboard+"&idemp="+idemployee+"&newlang="+lang,true);
	xmlhttp.send();

	}
function onclickEditGeneralNotice(idboard,action,els){
	if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else
	  {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp.onreadystatechange=function()
	  {
	  if (xmlhttp.readyState==4 && xmlhttp.status==200)
	    {

	        document.getElementById("generalnotice").innerHTML=xmlhttp.responseText;
	        
	        loadeditor();
	    }
	  }

	var lang = '<?=$_SESSION['lang']?>';
	xmlhttp.open("GET","admin/employeemanagement/new-general-notice.php?idboard="+idboard+"&action="+action+"&newlang="+lang,true);
	xmlhttp.send();

	function loadeditor(){
        var editor = CKEDITOR.replace("ncontent");
  	  	CKFinder.setupCKEditor(editor, '../ckfinder') ;
	}
}
</script>
<div id="contains" style="background-color: #edf4f7;">
	<div class="title">
		<div
			style="color: #0962C8; font-size: 12px; font-weight: bold; padding-left: 2px; padding-top: 8px; text-transform: uppercase;"></div>
	</div>
	<div class="body" style="margin-left: 5px;" id="generalnotice">
		<div style="height: 10px;"></div>
		<div class="navigation-button">
			<a href="#" onclick="onclickAddNewNotice(this);"><img
				src="images/new.png" /> </a>
			<div><?php echo $l_addnew?></div>
		</div>
		<br style="clear: both" /> <br />

		<table class="board" width="100%">
			<tr>
				<th align="center" width="5%"><?php echo $l_no?></th>
				<th width="3%"></th>
				<th width="50"><?php echo $l_title?></th>
				<th width="15%"><?php echo $l_author?></th>
				<th width="10%"><?php echo $l_created_date?></th>
				<th width="10%"><?php echo $l_views?></th>
				<th width="10%"></th>
			</tr>
			<?php
			$i =0;
			while ($row = mysql_fetch_array($loadboard)){
				$i++;
				?>
			<tr>
				<td align="center" width="5%"><?php echo $i;?>
				</td>
				<td align="left"><?php if($row[Type]=="VN"){?> <img
					src="images/flag_12.gif" height="15" width="18" /> <?php }else if($row[Type]=="KR"){?>
					<img src="images/flag_14.gif" height="15" width="18" /> <?php }?>
				</td>
				<td width="50"><a href="#" onclick="processPreviewNotice('<?=$row[ID]?>',this);"><?php echo $row[Title]?> </a>
				</td>
				<td align="center" width="15%"><?php echo $row[FullName]?></td>
				<td align="center" width="10%"><?php echo $row[CreatedDate]?></td>
				<td align="center" width="10%"><?php echo $row[View]?></td>
				<td align="center" width="10%">
					<a href="#" onclick="processPreviewNotice('<?=$row[ID]?>',this);" title="View"
						style="text-align: left;margin-left: -25px"> <img src="images/view.png" /> </a> 
					<a href="#" style="padding-left:15px;" onclick="onclickEditGeneralNotice('<?=$row[ID]?>','edit',this);" title="Edit"> <img src="images/edit-admin.png" /></a>
					<a href="#" style="padding-left:15px;" onclick="if(confirm('Are you sure?')){ processDeleteNotice('<?=$row[ID]?>','<?=$id_employee?>',this); return true;}else{return false;}" ><img src="images/delete-admin.png" /></a>
				</td>
				<?php }?>
		
		</table>

	</div>
</div>
